package com.victory.calculator.fragment;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.aries.ui.view.title.TitleBarView;
import com.victory.calculator.R;
import com.victory.calculator.adapter.ComputingAdapter;
import com.victory.calculator.entity.ComputingEntity;

import java.util.ArrayList;
import java.util.List;

import tech.com.commoncore.base.BaseTitleFragment;

@Route(path = "/calculator/fragment")
public class CalculatorFragment extends BaseTitleFragment {

    RecyclerView recyclerView;
    ComputingAdapter mAdapter;

    public static CalculatorFragment newInstance() {
        Bundle args = new Bundle();
        CalculatorFragment fragment = new CalculatorFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void setTitleBar(TitleBarView titleBar) {
        titleBar.setTitleMainText(getResources().getString(R.string.calculator_activity_title));
    }

    @Override
    public int getContentLayout() {
        return R.layout.calculator_fragment;
    }

    @Override
    public void initView(Bundle savedInstanceState) {
        recyclerView = mContentView.findViewById(R.id.rv_computing);
        recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
        mAdapter = new ComputingAdapter(R.layout.calculator_itme_computing);
        recyclerView.setAdapter(mAdapter);

        getDatas();

    }

    private void getDatas() {
        List<ComputingEntity> list = new ArrayList<>();
        list.add(new ComputingEntity(getResources().getString(R.string.calculator_one_title),getResources().getString(R.string.calculator_one_msg),0));
        list.add(new ComputingEntity(getResources().getString(R.string.calculator_two_title),getResources().getString(R.string.calculator_two_msg),0));
        list.add(new ComputingEntity(getResources().getString(R.string.calculator_three_title),getResources().getString(R.string.calculator_three_msg),0));
        list.add(new ComputingEntity(getResources().getString(R.string.calculator_four_title),getResources().getString(R.string.calculator_four_msg),0));
        mAdapter.setNewData(list);
    }


}
